import ProTable from '@ant-design/pro-table';
import type { ProColumns } from '@ant-design/pro-table';
import {  Modal } from 'antd';
import React from 'react';
import {Customer} from '../../model';
import PropTypes from 'prop-types';

class OutCustomer extends React.Component{

    static propTypes = {
        modalVisible:PropTypes.bool,
        values:PropTypes.array,
        onSubmit:PropTypes.func,
        onCancel:PropTypes.func,
    }
    
    state={
        selectedRowsState:[],
    }

    constructor(props){
        super(props);
    }

    columns: ProColumns<Customer>[] = [
        {
            title:'客户类型',
            dataIndex: 'type',
            valueType:'select',
            valueEnum:{
                1: { text: '客户' },
                2: { text: '客户' },
              },
            hideInTable:true
        },
        {
          title:'客户编码',
          dataIndex: 'custCode',
        },
        {
          title:"客户名称",
          dataIndex: 'custName',
        },
      ];

    render(){
        return (
            <Modal
                    title="选择收货方"
                    width={1000}
                    visible={this.props.modalVisible}
                    onOk={()=>{
                        this.props.onSubmit(this.state.selectedRowsState);
                    }}
                    onCancel={()=>{
                        this.props.onCancel();
                    }}
                >
                    <ProTable<Customer>
                    headerTitle='客户列表'
                    scroll={{ y: 240 }}
                    toolBarRender={false}
                    columns={this.columns}
                    search={{span:10}}
                    rowKey="key"
                    pagination={false}
     
                        rowSelection={{
                        onChange: (_, selectedRows) => {
                            this.setState({selectedRowsState:selectedRows})
                        },
                        }}
                    />
            </Modal>
        );
    }
}

export default OutCustomer;